//package com.pengzy.core.cloud_security;
//
//import com.alibaba.fastjson.JSONObject;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.pengzy.comment.web.result.JsonResult;
//import lombok.SneakyThrows;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.core.io.buffer.DataBuffer;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.server.reactive.ServerHttpResponse;
//import org.springframework.security.core.AuthenticationException;
//import org.springframework.security.web.server.authentication.HttpBasicServerAuthenticationEntryPoint;
//import org.springframework.stereotype.Component;
//import org.springframework.web.server.ServerWebExchange;
//import reactor.core.publisher.Mono;
//
//import java.util.HashMap;
//
///**
// * 接口认证入口类
// * @author xiaozhi 2023/7/17
// */
//@Slf4j
//@Component
//public class AuthenticationEntryPoint extends HttpBasicServerAuthenticationEntryPoint {
//
//
//    @SneakyThrows
//    @Override
//    public Mono<Void> commence(ServerWebExchange exchange, AuthenticationException e) {
//        log.info("接口认证入口类");
//        ServerHttpResponse response = exchange.getResponse();
//        response.setStatusCode(HttpStatus.UNAUTHORIZED);
//        response.getHeaders().add("Content-Type", "application/json; charset=UTF-8");
//        ObjectMapper objectMapper = new ObjectMapper();
//        DataBuffer bodyDataBuffer = response.bufferFactory().wrap(JSONObject.toJSONString(JsonResult.error(401,"未登录")).getBytes());
//        return response.writeWith(Mono.just(bodyDataBuffer));
//    }
//
//}
